<?php
list($app_id, $access_token, $sitemid, $time, $key, $request_ids, $is_install) = require_once 'inc.php';
?>
<!DOCTYPE html> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>找啊找啊找朋友</title>
<style type="text/css">
body { font:12px/1.5 Arial, Helvetica, sans-serif; }
body, ul, li { margin:0; padding:0; }
ul li { list-style:none; }
a { text-decoration:none; }
img { border:none; vertical-align:middle; }
.main { margin:auto; width:760px; }
.nav { background:url(public/navbg.png); padding:5px 10px 0; height:30px; line-height:30px; }
.nav li { float:left; padding-right:5px; }
.nav li a { padding:0 10px; display:inline-block; color:#ffffff; }
.nav .c a, .nav a:hover { background:#D9D9D9; color:#666666; }
.nav .c a { font-size:14px; font-weight:bold; }
.p10{padding:10px;}
.connet,.frlist{ background:#F7F7F7;}
.connet ul{padding:10px 200px;}
.connet h3{margin:0; padding:5px; font-size:16px;}
.connet h4,.frlist h4{border-bottom:1px dotted #cccccc; margin:0; padding:5px 0; font-size:12px; font-weight:normal}
.connet li { padding:5px 0; }
.connet li label { display:inline-block; width:80px; text-align:right; font-weight:bold; }
.frlist ul{padding:10px 5px;}
.frlist li h5{margin:0; padding:0;}
.frlist li{float:left; width:120px; padding:0 0 5px 60px; position:relative;}
.frlist li img{position:absolute; left:10px; top:0;}
a.but01{border:1px solid #D2D2D2; background:#666666; display:inline-block; padding:2px 5px; color:#ffffff;}
.clear{clear:both;}
</style>
<script src="http://connect.facebook.net/zh_TW/all.js"></script>
</head>
<body>

<div class="main">
	<div class="nav">
		<ul>
			<li class="c"><a href="#@">找好友</a></li>
		</ul>
	</div>
	<div class="connet p10">
		<h4>
			你当前位置：首页 >> 查找好友
		</h4>
		<ul class="p10">
			<h3> 请先选择您需要择友的条件： </h3>
			<li>
				<label>语言：</label>
		        <select id="locale">
		        	<option value="zh_CN">中文简体</option>
		        	<option value="zh_TW">中文繁体(台湾)</option>
		        	<option value="zh_HK">中文繁体(香港)</option>
		        	<option value="en_US">英语(美式)</option>
		        	<option value="en_HK">英语(英式)</option>
		        </select>
			</li>
			<li>
				<label>性别：</label>

				<input type="radio" id="male" 		name="gender" value="radio"> 男性
				<input type="radio" id="female" 	name="gender" value="radio"> 女性
				<input type="radio" id="all" 		name="gender" value="radio" checked="checked"> 不限性别
			</li>
			<li>
				<label>&nbsp;</label>
				<input id="btn_query" type="image" src="public/but.png" onclick="start_query()" disabled="disabled" />
			</li>
		</ul>
	</div>

	<div id="resultBox" class="frlist p10">
		<div id="loadingBar" style="display: none;" class="p10">正在加载，這大概需要十幾秒 <img src="public/loading.gif" /></div>
		<ul id="result" class="p10"> </ul>
		<div class="clear"></div>
	</div>
</div>

<div id="fb-root"></div>
<div id="json_rpc-root" class="z-h"></div>
<script>
var log_count = 100;
var endpoint = {
		query:	'http://ennea-findfriends.appspot.com/api/query',
		remove:	'http://ennea-findfriends.appspot.com/api/remove',
		log:		'http://ennea-findfriends.appspot.com/api/log'
};
var	app_id		= '<?php echo $app_id ?>',
access_token		= '<?php echo $access_token ?>',
sitemid				= '<?php echo $sitemid ?>';
/**
var	endpoint = {
		query:	'http://127.0.0.1:8080/api/query',
		remove:	'http://127.0.0.1:8080/api/remove',
		log:	'http://127.0.0.1:8080/api/log'
};
/**/
function load_script(url, callback) {
	var script = document.createElement('script');
	script.type = 'text/javascript';
	if (script.readyState) { /* IE */
		script.onreadystatechange = function() {
			if (script.readyState == 'loaded' || script.readyState == 'complete') {
				script.onreadystatechange = null;
				callback();
			}
		};
	} else script.onload = callback;
	script.src = url;
	document.getElementsByTagName('head')[0].appendChild(script);
}

var Qing = false;
function start_query() {
	if(Qing) return false;
	Qing = true;
	$('#all, #male, #female').each(function(i, x){
		if(x.checked){
			var	sex		= $(x).attr('id'),
					loc		= $('#locale').val(),
					offset	= Math.floor(Math.random()*3+1); // 0 - 10 之间的随机数
			loadData(sex, loc, offset);
		}
	});
}

try {
	typeof FB != 'undefined' && FB.init({ appId  : app_id, status : true, cookie : false, xfbml  : false });

	load_script( 'https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js',
	function() {
		load_script( 'public/funcs.js?1',
		function() {
			$('#btn_query').removeAttr('disabled');

		});
	});
} catch (e) {
	console && console.log(e);
}
</script>
</body>
</html>
